﻿using System;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using Microsoft.SharePoint;
using JM.JCY.Common;
using JM.JCY.Proxy;
using JM.JCY.BusinessEntity;

namespace JM.JCY.SharePointComponent.IncorruptArchives.DangFengLianZhengCePing
{
    public partial class DangFengLianZhengCePingUserControl : UserControl
    {
        string currentAccount = SPContext.Current.Web.CurrentUser.Name;
        string listName = JCYConstant.SharePointListName.DangFengLianZhengCePing;
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                SPWeb web = SPContext.Current.Web;
                SPList list = web.Lists[listName];
                this.lvDangFengLianZhengCePing.ListId = list.ID.ToString();
                if (currentAccount != "admin")
                {
                    //defualt user ListView == MyView (Display my records)
                    lvDangFengLianZhengCePing.ViewId = list.Views["MyView"].ID.ToString();
                }
                else
                {
                    //Manager ListView = All (Display all records)
                    lvDangFengLianZhengCePing.ViewId = list.Views["All"].ID.ToString();
                }

                string onclick = string.Format("javascript:NewItem2(event, '{0}');javascript:return false;", list.DefaultNewFormUrl);
                this.idHomePageNewItem.Attributes.Add("onclick", onclick);
            }
        }
    }
}
